Image processing device, image processing method, and record medium on which the same is recorded

ABSTRACT

The image processing apparatus extracts edge pixels of an input image, connects the edge pixels so as to extract a segment, extracts an inclination angle of the image based on the segment, corrects an inclination of the image based on the angle, determines that correction has ended when the corrected inclination is equal to or less than a predetermined threshold value, and repeats inclination extraction, inclination correction and end determination using an output image obtained after the inclination correction as a new input image until it is determined that correction has ended.

This application is the national phase under 35 U.S.C. § 371 of PCTInternational Application No. PCT/JP01/07339 which has an Internationalfiling date of Aug. 27, 2001, which designated the United States ofAmerica.

TECHNICAL FIELD

The present invention relates to an image processing apparatus forcorrecting an inclination of input image data, an image processingmethod and a record medium on which the same is recorded.

BACKGROUND ART

The center of the industry was shifted from the hardware industry to thesoftware industry in the process of its development in the past, and itis predicted that it will be shifted to the contents industry in thetwenty-first century. The closest target of the contents industry iselectronic books that have attracted attention in Japan and worldwide inrecent years. Among these, an electronic book based on images that canbe created at a low cost by applying an image processing technique isconsidered to be promising. Especially in Japan, “comic books” thataccount for a half of all the books made of paper in terms of sales areobjects thereof, so that the image-based electronic books will be thecenter thereof.

The image-based electronic books have the advantages that most of thecreation processes from (1) scanner input, (2) inclination correction,(3) various kinds of image processing, (4) manual modification/editingto (5) contents output can be automated based on the existing proof-readbooks, and the contents can be created at a very low cost. Then, thecontents data that will be commercial products have to be subjected toinclination correction with high precision, so that the process (2) ofinclination correction is particularly important in the creationprocesses.

The “inclination correction technique” for correcting an inclination ofan input image automatically already has been realized by an electronicfiling system, a pre-processing function of OCR (Optical CharacterReader) software or the like, and conventional techniques are disclosedin an “image processing apparatus” of Japanese Unexamined PatentPublication JP-A 9-120430 (conventional technique 1) and an “imagefiling apparatus” of Japanese Unexamined Patent Publication JP-A 1-64076(conventional technique 2).

The conventional technique 1 is a method in which when ruled lines orthe like are present in an image, coordinate strings for the outline ofan image are scanned so as to obtain the four corners of the outline, aslender shaped object is extracted as a segment from the four corners,and an inclination of the image is extracted from the most slendershaped segment of the extracted segments and is corrected.

The conventional technique 2 is a method in which under the preconditionthat a peripheral edge portion of an input original is white, an areaoutside the original at the time of image input is black, and theperipheral edge portion of the original is extracted based on thatinformation, and thus an inclination of the original is extracted basedon that edge information and is corrected.

In the conventional technique 1, when an isolated segment is present,stable properties can be obtained. In the conventional technique 2, whenthe peripheral edge of the original is white, stable performance can beobtained.

However, when these conventional techniques are applied to “comicbooks”, which are the most important in the image-based electronicbooks, then various problems of the “comic books” decrease correctionprecision. As a result, the number of manual processes for correction isincreased, so that the advantage (low cost conversion to electronicbooks) of image-based electronic books is compromised. The problems ofthe conventional techniques will be described more specifically below.

In the conventional technique 1, an object whose outline shape isslender is extracted as a segment, and therefore when a segment is incontact with a character or a picture (such a case is frequently presentin the comic books), the four corners of the outline of a segment cannotbe obtained, and the outline shape is not slender, so that thistechnique cannot be applied.

Furthermore, since only the most slender segment is used, a correctionresult can be an error when the segment inclines. This is because aframe line may be drawn obliquely on purpose in the comic books.

In the conventional technique 2, it is the precondition that theperipheral edge of an original is white, and a portion outside theoriginal at the time of image input is constituted by black pixels, sothat the peripheral edge can be extracted. However, for an original inwhich there is a picture in the periphery or an original whose peripheryis entirely black (these cases also occurs frequently in comic books),the peripheral edge of the original cannot be extracted precisely, and acorrection result may be an error.

As described above, when comic books are subjected to these techniques,these techniques cannot perform inclination correction with highprecision.

It is an object of the invention to provide an image processingapparatus that can perform inclination correction with high precisioneven if a segment present in an image is in contact with a character ora picture, an oblique segment which is a factor of a correction error ispresent, or the peripheral edge of an original is not white, an imageprocessing method and a record medium on which the same is recorded.

DISCLOSURE OF INVENTION

The invention provides an image processing apparatus for correcting aninclination of an input image, including:

edge extracting means for extracting edge pixels of an input image;

segment extracting means for extracting a segment by connecting the edgepixels extracted by the edge extracting means;

inclination extracting means for extracting an inclination angle of theimage based on the segment extracted by the segment extracting means;and

inclination correcting means for correcting an inclination of the imagebased on the inclination angle of the image extracted by the inclinationextracting means.

According to the invention, the image processing apparatus extracts edgepixels of an input image, connects the extracted edge pixels so as toextract a segment, extracts an inclination angle of the image based onthe extracted segment, and corrects an inclination of the image based onthe extracted inclination angle of the image. Therefore, even if asegment present in the input image is in contact with a character or apicture, even if an oblique, which is a factor of a correction error, ispresent, or even if the peripheral edge of the original is not white,inclination correction can be performed with high precision.

The invention is characterized in that the edge extracting means setspixel values in a central area of the input image to one and the samepredetermined pixel value as pre-processing for extracting edge pixels.

According to the invention, since the edge extracting means sets pixelvalues in an central area of the input image to one and the samepredetermined pixel value as pre-processing for extracting edge pixels,error factors present in the central area of the image such as obliquesegments are eliminated, so that the inclination correction performancecan be improved and inclination correction can be performed in a highspeed.

The invention is characterized in that the segment extracting meansincludes:

means for connecting edge pixels so as to extract edge coordinates;

means for scanning the edge coordinates so as to assign a code for adirection from each edge coordinate to the next edge coordinate; and

means for scanning the direction code of each edge coordinate, erasingan edge coordinate of a point whose direction code has a difference ofnot more than a predetermined threshold value in the inclination from anadjacent direction code thereof, storing an edge coordinate of aninflection point that has a difference larger than a predeterminedthreshold value in the inclination and storing an edge coordinate of theend point, extracting a new segment by connecting each point, andassigning a new direction code to the new segment.

According to the invention, the segment extracting means connects edgepixels so as to extract edge coordinates, scans the edge coordinates soas to assign a code for a direction from each edge coordinate to thenext edge coordinate, scans the direction code of each edge coordinate,erases an edge coordinate of a point whose direction code has adifference of not more than a predetermined threshold value in theinclination from an adjacent direction code thereof, stores an edgecoordinate of an inflection point that has a difference larger than apredetermined threshold value in the inclination and stores an edgecoordinate of the end point, further extracts a new segment byconnecting each point, and assigns a new direction code to the newsegment. Thus, each segment can be extracted from the edge coordinates.

The invention is characterized in that the segment extracting meansscans the segments to which the new direction code is assigned, andextracts a segment whose segment length is longer than a predeterminedthreshold value and whose inclination in the direction code is in apredetermined range as a horizontal segment or a vertical segment.

According to the invention, the segment extracting means scans thesegments to which the new direction code is assigned, and extracts asegment whose segment length is longer than a predetermined thresholdvalue and whose inclination in the direction code is in a predeterminedrange as a horizontal segment or a vertical segment. Therefore,extremely oblique segments or short segments that are unwanted forinclination correction can be removed.

The invention is characterized in that the inclination extracting meansextracts an angle of each segment with respect to all the extractedsegments, multiplies the extracted angle of each segment by a weightobtained by taking the sum of the length of all the segments as adenominator and the length of each segment as a numerator, and extractsa value obtained by adding all the segment angles with the weight as aninclination angle of the image.

According to the invention, the inclination extracting means extractseach segment angle with respect to all the extracted segments,multiplies the extracted angle of each segment by a weight obtained bytaking the sum of the length of all the segments as a denominator andthe length of each segment as a numerator, and extracts a value obtainedby adding all the segment angles with the weight as an inclination angleof the image. Therefore, the longer the segment is, the more likely itis that the inclination angle thereof is used, and the hardly the angleof a segment that can be an error factor is reflected.

In another aspect, the invention provides an image processing apparatusfor correcting an inclination of an input image including:

inclination extracting means for extracting an inclination with respectto an input image;

inclination correcting means for correcting an inclination of the imagebased on the inclination extracted by the inclination extracting means;and

end determining means for determining that correction has ended when theinclination corrected by the inclination correcting means is equal to orless than a predetermined threshold value,

wherein inclination extraction, inclination correction and enddetermination are repeated using an output image obtained after theinclination correction as a new input image until the end determiningmeans determines that correction has ended.

According to the invention, an image processing apparatus extracts aninclination with respect to an input image, corrects an inclination ofthe image based on the extracted inclination, determines that correctionhas ended when the corrected inclination is not more than apredetermined threshold value. When the inclination is larger than apredetermined threshold value, the apparatus repeats inclinationextraction, inclination correction and end determination using an outputimage obtained after the inclination correction as a new input image,until it is determined that correction has ended. Thus, the precision ofinclination correction can be improved.

In another aspect, the invention provides an image processing method forcorrecting an inclination of an input image including:

extracting edge pixels of an input image;

connecting the extracted edge pixels so as to extract a segment;

extracting an inclination angle of the image based on the extractedsegment; and

correcting an inclination of the image based on the extractedinclination angle of the image.

According to the image processing method of the invention, edge pixelsof an input image are extracted, the extracted edge pixels are connectedso as to extract a segment, an inclination angle of the image isextracted based on the extracted segment, and an inclination of theimage is corrected based on the extracted inclination angle of theimage. Therefore, even if a segment present in the input image is incontact with a character or a picture, even if an oblique, which is afactor of a correction error, is present, or even if the peripheral edgeof the original is not white, inclination correction can be performedwith high precision.

In another aspect, the invention provides an image processing method forcorrecting an inclination of an input image including the steps of:

extracting an inclination with respect to an input image;

correcting an inclination of the image based on the extractedinclination; and

determining that correction has ended when the corrected inclination isequal to or less than a predetermined threshold value, wherein

when the corrected inclination is larger than a predetermined thresholdvalue, inclination extraction, inclination correction and enddetermination are repeated using an output image obtained after theinclination correction as a new input image, until it is determined thatcorrection has ended.

According to the image processing method of the invention, aninclination is extracted with respect to an input image, an inclinationof the image is corrected based on the extracted inclination, it isdetermined that correction has ended when the corrected inclination isequal to or less than a predetermined threshold value, and when theinclination is larger than a predetermined threshold value, inclinationextraction, inclination correction and end determination are repeatedusing an output image obtained after the inclination correction as a newinput image, until it is determined that correction has ended. Thus, theprecision of inclination correction can be improved.

In another aspect, the invention provides a computer-readable recordmedium storing a program for letting a computer execute an imageprocessing method including the steps of:

extracting edge pixels of an input image;

connecting the extracted edge pixels so as to extract a segment;

extracting an inclination angle of the image based on the extractedsegment; and

correcting an inclination of the image based on the extractedinclination angle of the image.

According to the invention, the computer-readable record medium storinga program to be executed by a computer stores an image processing methodincluding extracting edge pixels of an input image, connecting theextracted edge pixels so as to extract a segment, extracting aninclination angle of the image based on the extracted segment, andcorrecting an inclination of the image based on the extractedinclination angle of the image. Therefore, even if a segment present inthe input image is in contact with a character or a picture, even if anoblique, which is a factor of a correction error, is present, or even ifthe peripheral edge of the original is not white, inclination correctioncan be performed with high precision.

In another aspect, the invention provides a computer-readable recordmedium storing a program for letting a computer execute an imageprocessing method including the steps of:

extracting an inclination with respect to an input image;

correcting an inclination of the image based on the extractedinclination, and

determining that correction has ended when the corrected inclination isequal to or less than a predetermined threshold value, wherein

when the corrected inclination is larger than a predetermined thresholdvalue, inclination extraction, inclination correction and enddetermination are repeated using an output image obtained after theinclination correction as a new input image, until it is determined thatcorrection has ended.

According to the invention, the computer-readable record medium storinga program to be executed by a computer stores an image processing methodincluding extracting an inclination with respect to an input image,correcting an inclination of the image based on the extractedinclination, determining that correction has ended when the correctedinclination is equal to or less than a predetermined threshold value,and repeating inclination extraction, inclination correction and enddetermination using an output image obtained after the inclinationcorrection as a new input image until it is determined that correctionhas ended, when the inclination is larger than a predetermined thresholdvalue. Thus, inclination correction can be performed with highprecision.

BRIEF DESCRIPTION OF DRAWINGS

Other and further objects, features, and advantages of the inventionwill be more explicit from the following detailed description taken withreference to the drawings wherein:

FIG. 1 is a schematic drawing showing a comic image 1 that has beeninput with a portion outside an original being black;

FIG. 2 is a schematic drawing showing an extracted image 2 in which edgepixels are extracted from the comic image 1 shown in FIG. 1;

FIG. 3 is a schematic diagram for explaining eight connections of edgepixels;

FIGS. 4A and 4B is a schematic diagram for explaining assignment ofdirection codes;

FIG. 5 is a schematic drawing showing a segment extracted image 5 thatis drawn by new segments extracted from the extracted image 2 shown inFIG. 2;

FIG. 6 is a schematic drawing showing a segment extracted image 6 inwhich horizontal segments and vertical segments are extracted from thesegment extracted image 5 shown in FIG. 5;

FIG. 7 is a schematic drawing showing a comic image 9 that has beencorrected with respect to the inclination by an image processingapparatus that is an embodiment of the present invention;

FIG. 8 is a flowchart for explaining an image processing procedure bythe image processing apparatus; and

FIG. 9 is a block diagram showing a CPU (central processing unit) 11 anda work memory portion 12 of an image processing apparatus that is anembodiment of the present invention.

BEST MODE FOR CARRYING OUT THE INVENTION

Hereinafter, embodiments of the present invention will be described bytaking a general comic image as an example.

FIG. 1 is a schematic drawing showing a comic image 1 that has beeninput with a portion outside an original being black. As shown in FIG.1, the comic image 1 includes a cut-off portion (portion in which thedrawing is present up to the edge of the original) 1 a, a portion 1 b ofthe peripheral edge of the original that is colored black, and a frameline 1 c that is drawn obliquely on purpose. However, most frame linesdrawn in the vicinity of the periphery of the original, extend in thehorizontal direction that is parallel to the upper side and the lowerside of the original, such as a frame line 1 d, or in the verticaldirection that is parallel to the left side and the right side of theoriginal, and few oblique frame lines are drawn beyond the portion inwhich drawings are present. In other words, most of the frame linesdrawn in the vicinity of the periphery of the original are linesextending in the horizontal direction or the vertical direction. Someframe lines are present isolated, but many of the frame lines, such as aframe line 1 e, are in contact with a picture or a screen tone. There isa side on which the entire peripheral edge of the original is white,such as a side 1 f.

Next, an image processing method with an image processing apparatus thatis an embodiment of the present invention will be described. The imageprocessing apparatus includes edge extracting means for extracting edgepixels of an input image, segment extracting means for connecting theextracted edge pixels so as to extract a segment, inclination extractingmeans for extracting an inclination angle of the image based on theextracted segment, inclination correcting means for correcting aninclination of the image based on the extracted inclination angle of theimage, and end determining means for performing end determination basedon the extracted inclination. The image processing apparatus performsimage processing in which an inclination of an original with respect toan input image such as the comic image 1 shown in FIG. 1 is corrected,that is, correction is performed such that the peripheral edge of theoriginal is parallel to the vertical frame and the horizontal frame ofthe input image.

When the comic image 1 shown in FIG. 1 is input, the image processingapparatus focuses on segments in the horizontal direction and thevertical direction in a peripheral area of a dominant image, andtherefore, first, the central area of the input comic image 1 is maskedwith background pixels that are for a portion outside the frame of theoriginal, that is, white pixels in this embodiment. In other words, thepixel values in the central area are set to one and the samepredetermined pixel value. The shape of the central area to be maskedcan be arbitrary, such as a circle or a rectangle. In this embodiment,the shape of the central area is a rectangle, and the length in thelongitudinal direction is ⅓ of that of the input image, and the lengthin the width direction is ⅓ of the input image. Since error factors(e.g., oblique segments) present in the central portion of the image areeliminated by masking the central area in this manner, the performanceof inclination correction can be improved and inclination correction canbe performed in a high speed. It should be noted that the same resultscan be obtained when image processing is performed in the manner thatwill be described below with respect to all pixels, and the portion nearthe center is ignored at the final stage, but in this case, theprocessing speed can be reduced because processing with respect tounnecessary pixels is required.

Then, the edge pixels of the masked image are extracted by the edgeextracting means. This is performed by scanning the image in the twodirections, that is, from up to down and from left to right, andextracting a focused pixel as an edge pixel, when the focused pixel is ablack pixel and the immediately previous pixel value is a white pixel orthe immediately following pixel value is a white pixel.

FIG. 2 is a schematic drawing showing an extracted image 2 in which edgepixels are extracted from the comic image 1 shown in FIG. 1. When ahuman looks at the extracted image 2 shown in FIG. 2, he/she has thefalse impression that segments are extracted from the comic image 1.However, in reality, simply the extracted edge pixels are displayedblack and other non-extracted pixels are displayed white, andinformation on segments or the like cannot be obtained.

Referring to the extracted image 2, in a portion 2 a corresponding tothe cut-off portion 1 a shown in FIG. 1 and a portion 2 b correspondingto the portion 1 b shown in FIG. 1 in which the peripheral edge of theoriginal is colored black, there is no difference from a portion outsidethe original that is input so as to be black, and the edge of theoriginal is unstable. In the masked area 2 c, which is the central areain FIG. 2, oblique segments are significantly eliminated by masking, andthis area is displayed as a white rectangle. Furthermore, when theportion outside the original is input with black pixels as shown in FIG.1, the side 2 f corresponding to the side 1 f in FIG. 1 whose peripheryis constituted by distinct white pixels is the longest edge segment.

Then, an edge coordinate string is created by connecting edge pixels bythe segment extracting means. FIG. 3 is a schematic diagram forexplaining connection of eight edge pixels. As shown in FIG. 3, theconnection of edge pixels is performed in the following manner, forexample. A unconnected edge pixel 3 d having a two-dimensionalcoordinate (x, y) is taken as a focused pixel, an unconnected edge pixel3 a having a coordinate (x+1, y) that is the first pixel of the eightneighboring pixels when viewed in a predetermined direction, that is,clockwise in this embodiment, is connected to the focused pixel.Thereafter, the connected edge pixel 3 a is taken as a new focusedpixel, and the same processing is repeated until unconnected pixels areno longer present in the eight neighboring pixels.

Thus, the edge pixels are converted to an edge coordinate string (Xi,Yi) of a string. As for the edge coordinate strings, for example, in thecase of one character, one coordinate string is created with theoutermost contour (or innermost contour) thereof.

Then, a direction code is assigned to the edge coordinate string by thesegment extracting means. FIG. 4 is a schematic diagram for explainingassignment of direction codes. In FIG. 4, one coordinate of a coordinatestring is shown by an arrow starting with a black circle, and the arrowindicates its direction. Here, first, as shown in FIG. 4A, thecoordinate string is scanned and a direction code is assigned withrespect to the direction from the focused coordinate to the nextcoordinate. The direction code of this embodiment is a vector codeobtained by quantizing the direction with 64 codes in a counterclockwiserotation of 360 degrees. Direction code 1 and direction code 33 aredirection codes for the horizontal direction. Direction code 17 anddirection code 49 are direction codes for the vertical direction.

Furthermore, as shown in FIG. 4B, each edge coordinate and the directioncode thereof are scanned, the edge coordinate of a point whose directioncode has a difference of not more than a predetermined threshold valuein the inclination from an adjacent direction code thereof is erased,and the edge coordinate of a point (inflection point 4 b) that has adifference larger than a predetermined threshold value in theinclination and the edge coordinates of the end points 4 a and 4 c arestored.

A new segment 4 d connecting a section 1 between the end point 4 a andthe inflection point 4 d and a new segment 4 e connecting a section mbetween the end point 4 c and the inflection point 4 d are extractedbased on the stored edge coordinates. For the extracted segments 4 d and4 e, a new direction code is recalculated based on the coordinates ofboth the ends thereof, and a new direction code is assigned. FIG. 5 is aschematic drawing showing a segment extracted image 5 that is drawn withnew segments extracted from the extracted image 2 shown in FIG. 2.

Then, the segment extracting means erases all the segments exceptsegments having the direction code 1 and the direction code 33indicating the horizontal direction and segment having the directioncode 17 and the direction code 49 indicating the vertical direction, anderases segments having a segment length of not more than a predeterminedthreshold value from all the extracted segments. In other words,horizontal segments and vertical segments having a length larger than apredetermined threshold value are kept present. More specifically, thisis processing by which segments that are substantially horizontal orvertical with a difference in the range of ±5.6 degrees are keptpresent, because one direction code has a range of 360/64=5.6 degrees.Thus, extremely oblique segments are deleted. FIG. 6 is a schematicdrawing showing a segment extracted image 6 in which horizontal segmentsand vertical segments are extracted from the segment extracted image 5shown in FIG. 5.

Then, the inclination extracting means extracts an inclination angle anda segment length of each segment, and calculates an inclination angle ofthe image. The calculation of an inclination angle is performed by theinclination extracting means in the following manner. With respect toall the extracted segments, the angle of each segment extracted from thedirection code is multiplied by a weight obtained by taking the sum ofthe length of all the extracted segments as a denominator and the lengthof each segment as a numerator, and a value obtained by adding all thesegment angles with the weight is extracted as an inclination angle ofthe image. In this method for extracting an inclination angle, thelonger the segment is, the more likely it is that the inclination anglethereof is used. Thus, even if a moderately oblique segment, which maybe an inclination extraction error factor, is present near the center ofthe image, the extracted segment is short because of an effect ofmasking. Therefore, a moderately oblique angle, which causes an error,is hardly reflected. Extremely oblique segments are already deleted inthe previous processing, so that moderately oblique segments aretargeted in this processing.

Then, the inclination correcting means corrects the inclination byrotating the image, based on the obtained inclination angel of theimage. In the above inclination correction, when the inclination of theimage is large, the edge pixels become unstable, and one segment on theoriginal is divided into a plurality of segments and extracted. Thus,inclination extraction is performed with short segments, so that thecorrection precision is decreased.

In this embodiment, in order to avoid it, it is determined whether ornot the absolute value of the extracted inclination angle is not morethan a predetermined threshold value by end determining means at the endof the image processing. When it is equal to or less than a thresholdvalue, processing is ended, and when it is larger than the thresholdvalue, inclination extraction is performed again, using the correctedimage as an input image, and inclination extraction, inclinationcorrection and end determination are repeated until it is determinedthat processing has ended. The inclination correction precision can beimproved by repeating inclination extraction, inclination correction andend determination in this manner. FIG. 7 is a schematic drawing showinga comic image 9 that has been corrected with respect to the inclination.

FIG. 8 is a flowchart for explaining an image processing procedure bythe image processing apparatus. FIG. 9 is a block diagram showing a CPU(central processing unit) 11 and a work memory portion 12 of an imageprocessing apparatus that is an embodiment of the present invention. Thework memory portion 12 includes an original image buffer (BO), an inputimage buffer (BI), an edge image buffer (BE), a coordinate string buffer(BP), a segment buffer (BL) and a correction image buffer (BR), and iscontrolled by the CPU 11.

First, in step S501, an image input to the image processing apparatus isstored in the original image buffer (BO) and the input image bufferportion (BI).

Then, the pixel values of the central area of the input image buffer(BI) are replaced by the pixel value for the background, which isoutside the frame on the original of the image. The shape of the centralarea can be an arbitrary shape such as a circle or a rectangle. In thisembodiment, the shape of the central area is a rectangle, and the lengthin the longitudinal direction is ⅓ of that of the input image, and thelength in the width direction is ⅓ of the input image. Since amonochrome binary image (1 for black image and 0 for white image) isused in this embodiment, the white pixel value 0 is used for the pixelvalue for the color of the entire central area. The masked image isstored in the input image buffer (BI) as it is (S502).

Then, the input image buffer (BI) is scanned sequentially in twodirections, that is, from up to down and from left to right. When thefocused pixel is a black pixel (1) and an immediately previous pixelvalue is a white pixel (0) or an immediately following pixel value is awhite pixel (0), then the focused pixel is extracted as an edge pixeland the corresponding pixel value of the edge image buffer (BE) is setto 1. When the above condition is not met, the corresponding pixel valueof the edge image buffer (BE) is set to 0, taking the focused pixel as anon-edge pixel, regardless whether it is black or white. As a result ofscanning all the pixels of the input image from up to down and from leftto right, an edge pixel is stored in the edge image buffer (BE) as apixel value 1, and a non-edge pixel is stored in the edge image buffer(BE) as a pixel value 0 (S503).

Then, an edge pixel in the edge image buffer (BE) is taken as thefocused pixel, and the focused pixel is connected to the first edgepixel in a clockwise rotation of neighboring eight connection pixels.Thus, two-dimensional binary image data (information only of 0 and 1)are converted to a connected edge coordinate string (Xi, Yi). Theconverted coordinate string is stored in the coordinate string buffer(BP) (S504).

Then, the coordinate string buffer (BP) is scanned, and a code for adirection from the focused coordinate (Xi, Yi) to the next coordinate(Xi+1, Yi+1) is assigned. In this embodiment, 64 direction codes (1, 2,3, . . . 64) obtained by quantizing the direction with 64 codes in acounterclockwise rotation of 360 degrees are used. Therefore, directionshaving an angle difference of 360/64=5.6 degrees are set to be given thesame direction code. The results thereof are stored in the directioncode portion (Di) of the coordinate string buffer (BP) (S505).

Then, the direction code portion (Di) of the coordinate string buffer(BP) is scanned, and the edge coordinate of a point whose direction codehas a difference of not more than a predetermined threshold value in theinclination from an adjacent direction code thereof is erased, and theedge coordinate of a point having a difference larger than apredetermined threshold value in the inclination and the edgecoordinates of the end points are stored. Furthermore, a new segmentconnecting a section between the end point and the inflection point isextracted based on the stored edge coordinates, and a new direction codeis assigned. As a result, the direction code of the new segment and thecoordinates of both the ends of the segment are stored in the segmentbuffer (BL) (S506).

Then, the segment buffer (BL) is scanned, and the segments that are notsegments having a direction code indicating the horizontal direction(direction code 1 and direction code 33) and segment having a directioncode indicating the vertical direction (direction code 17 and directioncode 49) and have a segment length of not more than a predeterminedthreshold value are erased. The remaining results are overwritten in thesegment buffer (BL) (S507).

Then, the segment buffer (BL) is scanned, and an inclination angle θ ofthe image is calculated based on the length and the angle of all theextracted horizontal and vertical segments from Formula 1 (S508)

Formula 1

$\begin{matrix}{\theta = {\sum\limits_{i}^{N}\;{\frac{L\; i}{L\; T}A\; i}}} & (1)\end{matrix}$where N: the number of horizontal and vertical segments,

LT: the total sum of all the segment lengths,

Li: the segment length of the i^(th) segment, and

Ai: the inclination angle of the i^(th) segment.

Then, the input image buffer (BI) is rotated based on the inclinationangle θ of the extracted image so as to correct the inclination. Thecorrected image is stored in the corrected image buffer (BR) (S509).

Then, it is determined whether or not the absolute value of theextracted inclination angle θ of the image is equal to or less than apredetermined threshold value. When it is equal to or less than apredetermined threshold value, the processing is ended (S510). When theinclination angle θ of the image is larger than the predeterminedthreshold value, the content of the corrected image buffer (BR) iscopied to the input image buffer (BI) (S511), and the procedure goesback to S502 for performing inclination extraction and inclinationcorrection again. Thereafter, steps S502 to S511 are repeated until itis determined that processing has ended at the end determination atS510, so that the inclination of the image is corrected with highprecision.

The image processing method can be recorded in a computer-readablerecord medium as a program to be executed on a computer such as an imageprocessing apparatus.

The invention may be embodied in other specific forms without departingfrom the spirit or essential characteristics thereof. The presentembodiments are therefore to be considered in all respects asillustrative and not restrictive, the scope of the invention beingindicated by the appended claims rather than by the foregoingdescription and all changes which come within the meaning and the rangeof equivalency of the claims are therefore intended to be embracedtherein.

INDUSTRIAL APPLICABILITY

According to the present invention, the image processing apparatus canperform inclination correction with high precision, even if a segmentpresent in an image is in contact with a character or a picture, anoblique segment, which is a factor of a correction error, is present, ora peripheral edge of an original is not white. Therefore, inclinationcorrection of, for example, comic images can be performed in a highspeed and high precision.

1. An image processing apparatus for correcting an inclination of aninput image, comprising: edge extracting means for extracting edgepixels of an input image; segment extracting means for extracting asegment by connecting the edge pixels extracted by the edge extractingmeans; inclination extracting means for extracting an inclination angleof the image based on the segment extracted by the segment extractingmeans; and inclination correcting means for correcting an inclination ofthe image based on the inclination angle of the image extracted by theinclination extracting means, wherein the edge extracting means setspixel values in a central area of the input image to one and the samepredetermined pixel value.
 2. The image processing apparatus of claim 1,wherein the edge extracting means extracts edge pixels of an imagehaving the pixel values in the central area set to one and the samepredetermined pixel value.
 3. An image processing apparatus forcorrecting an inclination of an input image, comprising: edge extractingmeans for extracting edge pixels of an input image; segment extractingmeans for extracting a segment by connecting the edge pixels extractedby the edge extracting means; inclination extracting means forextracting an inclination angle of the image based on the segmentextracted by the segment extracting means; and inclination correctingmeans for correcting an inclination of the image based on theinclination angle of the image extracted by the inclination extractingmeans, wherein the segment extracting means includes: means forconnecting edge pixels so as to extract edge coordinates; direction codeassigning means for scanning the edge coordinates so as to assign a codefor a direction from each edge coordinate to the next edge coordinate;and second direction code assigning means for assigning a new directioncode to a new segment by connecting an edge coordinate based on adifference in the inclination between a direction code and an adjacentdirection code thereof and an edge coordinate of the end point.
 4. Theimage processing apparatus of claim 3, wherein the second direction codeassigning means scans the direction code of each edge coordinate, erasesan edge coordinate of a point whose direction code has a difference ofnot more than a predetermined threshold value in the inclination from anadjacent direction code thereof, stores an edge coordinate of aninflection point that has a difference larger than a predeterminedthreshold value in the inclination and stores an edge coordinate of theend point, extracting a new segment by connecting each point, andassigns a new direction code to the new segment.
 5. The image processingapparatus of claim 3, wherein the segment extracting means scans thesegments to which the new direction code is assigned, and extracts asegment whose segment length is longer than a predetermined thresholdvalue and whose inclination in the direction code is in a predeterminedrange as a horizontal segment or a vertical segment.
 6. An imageprocessing apparatus for correcting an inclination of an input image,comprising: edge extracting means for extracting edge pixels of an inputimage; segment extracting means for extracting a segment by connectingthe edge pixels extracted by the edge extracting means; inclinationextracting means for extracting an inclination angle of the image basedon the segment extracted by the segment extracting means; andinclination correcting means for correcting an inclination of the imagebased on the inclination angle of the image extracted by the inclinationextracting means, wherein the inclination extracting means extracts anangle of each segment with respect to all the extracted segments,multiplies the extracted angle of each segment by a weight obtained bytaking the sum of the length of all the segments as a denominator andthe length of each segment as a numerator, and extracts a value obtainedby adding all the segment angles with the weight as an inclination angleof the image.
 7. The image processing apparatus of claim 1, furthercomprising: end determining means for determining that correction hasended when the inclination corrected by the inclination correcting meansis equal to or less than a predetermined threshold value, whereininclination extraction, inclination correction and end determination arerepeated using an output image obtained after the inclination correctionas a new input image until the end determining means determines thatcorrection has ended.
 8. An image processing method for correcting aninclination of an input image comprising: extracting edge pixels of aninput image; connecting the extracted edge pixels so as to extract asegment; extracting an inclination angle of the image based on theextracted segment; and correcting an inclination of the image based onthe extracted inclination angle of the image, wherein the step ofextracting edge pixels includes a step of setting each pixel value in acentral area of the input image to the same predetermined pixel value.9. The image processing method according to claim 8, further comprisingthe step of: determining that correction has ended when the correctedinclination is equal to or less than a predetermined threshold value,wherein when the corrected inclination is larger than a predeterminedthreshold value, inclination extraction, inclination correction and enddetermination are repeated using an output image obtained after theinclination correction as a new input image, until it is determined thatcorrection has ended.
 10. A computer-readable record medium storing aprogram for letting a computer execute an image processing methodcomprising the steps of: extracting edge pixels of an input image;connecting the extracted edge pixels so as to extract a segment;extracting an inclination angle of the image based on the extractedsegment; and correcting an inclination of the image based on theextracted inclination angle of the image, wherein the step of extractingedge pixels includes a step of setting each pixel value in a centralarea of the input image to the same predetermined pixel value.
 11. Thecomputer-readable record medium according to claim 10, the imageprocessing method further comprising the step of: determining thatcorrection has ended when the corrected inclination is equal to or lessthan a predetermined threshold value, wherein when the correctedinclination is larger than a predetermined threshold value, inclinationextraction, inclination correction and end determination are repeatedusing an output image obtained after the inclination correction as a newinput image, until it is determined that correction has ended.